// pages/balance/balance.js
var util = require('../../utils/util.js')
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    myMoney: 0.00,
    submitload: false,	//提交Loading状态
    infoList: [],
    rid: 0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getMyMoney()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
	app.publicchangenavigate()
    //获取充值状态
    var ists = wx.getStorageSync('rechargeist')
    if (ists == 1) {
      this.getMyMoney()
    }
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var ists = wx.getStorageSync('rechargeist')
    if (ists == 1) {
      this.getMyMoney()
    }
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },
  /**
   * 获取我的余额
   */
  getMyMoney: function () {
    var that = this
    //app.globalData.userInfoId
    var uid = app.globalData.userInfoId
    //开启加载
    that.setData({ submitload: true })
    //提交给服务端注册信息
    util.AJAX('Home/Recharge/getMyMoney', { uid: uid }, function (res) { //方法体
      //关闭加载
      that.setData({ submitload: false })

      if (res.data.StatusCode == 200) {  //成功
        //wx.removeStorageSync('ist')
        if (res.data.Moneys == null) {
          var Moneys = 0.00
        } else {
          var Moneys = res.data.Moneys
        }
        that.setData({ myMoney: Moneys })
      } else {	//失败

      }
    }, 'POST')
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
	return app.globalshare();
  },
  RechargeTap:function(){
	  app.publicnavigateTologing('/pages/Recharge/Recharge')
  },
  RechargeRecordTap:function(){
	  app.publicnavigateTologing('/pages/Recharge/RechargeRecord/RechargeRecord')
  },
  ExpenseTap: function () {
    app.publicnavigateTologing('/pages/balance/Expense/Expense')
  }
})